package com.blame.ollama.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 何彦声
 * Date: 2025-08-28
 * Time:
 */

@RequestMapping("/chatClient")
@RestController
public class ChatClientController {

    private final ChatClient chatClient;

    public ChatClientController(ChatClient chatClient) {
        this.chatClient = chatClient;
    }

    @RequestMapping("/call")
    public String call(String message){
        return chatClient.prompt(message).call().content();
    }

    @RequestMapping("/stream")
    public Flux<String> stream(String message){
        return chatClient.prompt(message).stream().content();
    }
}
